<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IList<KingSite.Shop.Domain.Category>>" %>
<link rel="stylesheet" type="text/css" href="<%= ViewData["ThemePath"] %>/Content/LeftNav.css" />

<script type="text/javascript">

    //SuckerTree Vertical Menu (Aug 4th, 06)
    //By Dynamic Drive: http://www.dynamicdrive.com/style/

    var menuids = ["suckertree1"] //Enter id(s) of SuckerTree UL menus, separated by commas

    function buildsubmenus() {
        for (var i = 0; i < menuids.length; i++) {
            var ultags = document.getElementById(menuids[i]).getElementsByTagName("ul")
            for (var t = 0; t < ultags.length; t++) {
                ultags[t].parentNode.getElementsByTagName("a")[0].className = "subfolderstyle"
                ultags[t].parentNode.onmouseover = function() {
                    this.getElementsByTagName("ul")[0].style.display = "block"
                }
                ultags[t].parentNode.onmouseout = function() {
                    this.getElementsByTagName("ul")[0].style.display = "none"
                }
            }
        }
    }

    if (window.addEventListener)
        window.addEventListener("load", buildsubmenus, false)
    else if (window.attachEvent)
        window.attachEvent("onload", buildsubmenus)

</script>
<div class="suckerdiv">
    <ul id="suckertree1">
        <%var rootList = from a in Model where a.ParentId.Equals(0) select a; %>
        <% foreach (var r in rootList) { %>
        <dt>
            <%= r.Name %></dt>
        <% var fList = from a in Model where a.ParentId.Equals(r.Id) select a; %>
        <% foreach (var f in fList) {%>
        <li>
            <% var sList1 = from a in Model where a.ParentId.Equals(f.Id) select a;%>
            <a href="/goods/list/<%= f.Path%>">
                <%= f.Name %>&nbsp;-&nbsp;<%int i = 1; %><span><%foreach (var ss in sList1) {%>
                    <%if (i <= 2) {%><%= ss.Name %>&nbsp;&nbsp;<%} %><%i++;
                                                                 } %></span> </a>
            <% var sList = from a in Model where a.ParentId.Equals(f.Id) select a;%>
            <%IList<Category> list2 = sList.ToList(); %>
            <ul>
                <%for (int j = 0; j <= list2.Count - 1; j++) {%>
                <li>
                        <span><a href="/goods/list/<%= list2[j].Path%>"><%= list2[j].Name%></a></span>
<%--                        <%if (j <= list2.Count-2) {%><span style="float: left;"><a href="#"><%= list2[j+1].Name%></a></span><%} %>
                        <%j = j + 2; %>--%>
                </li>
                <%} %>
            </ul>
        </li>
        <%}%>
        <%}%>
    </ul>
</div>

